package edu.suda.xsap.dto.convert;

import edu.suda.xsap.entity.ChartData;
import edu.suda.xsap.dto.CourseDto;
import edu.suda.xsap.entity.Course;
import edu.suda.xsap.entity.CourseCount;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper(componentModel = "spring")
public interface CourseConvert {

    @Mapping(source = "name", target = "courseName")
    @Mapping(source = "duration", target = "courseDuration")
    @Mapping(source = "contains", target = "courseCapacity")
    @Mapping(source = "color", target = "courseColor")
    @Mapping(source = "introduce", target = "courseIntroduction")
    @Mapping(source = "timesCost", target = "courseTimesCost")
    @Mapping(source = "limitSex", target = "courseLimitSex")
    @Mapping(source = "limitAge", target = "courseLimitAge")
    @Mapping(source = "limitCounts", target = "courseLimitCounts")
    @Mapping(source = "createTime", target = "courseCreateTime")
    @Mapping(source = "lastModifyTime", target = "courseLastModifyTime")
    @Mapping(source = "version", target = "courseVersion")
    CourseDto toDto(Course course);

    List<CourseDto> toDtoList(List<Course> courses);

    @Mapping(source = "courseName", target = "name")
    @Mapping(source = "courseTimes", target = "value")
    ChartData toCountDto(CourseCount courseCount);

    List<ChartData> toCountDtoList(List<CourseCount> courseCounts);
}